<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="./css/denglu.css">
    <link rel="stylesheet" href="./css/reset.css">
    <script src="./js/axios.js"></script>
</head>
<body>
    <div class="ee1">
     <div class="ee5">
        <img src="https://cdn.web-global.fds.api.mi-img.com/mcfe--mi-account/static/static/media/banner.4994397e.jpg" alt="">
        </div>
        <div class="ee2">
            <div class="ee3">
                <div class="ee4">
                    <img src="./img/icon-小米归属.png" alt="">
                    <span>小米账号</span>
                </div>

            </div>
            <div class="ee6">
                <div class="ee7">
                    <div class="ee8">
                        <span><a href="denglu.html">登录</a></span><span><a href="zhuce.html">注册</a></span>
                 
                    </div>  
                       <div class="ee9">
                            <input type="text" class="oipt" name="" id="" >
                            <p class="ts"></p>
                            
                        </div>
                        <div class="ff2">
                            <input type="text" class="tipt" name="" id="" >
                            <p class="tts"></p>
                            
                        </div>
                        <div class="ee10">
                            <input type="checkbox" class="hipt">
                            <span>已阅读并同意小米帐号 用户协议 和 隐私政策</span>
                        </div>
                        <input type="button" value="登录" class="ff1">
                </div>
            </div>
        </div>
    </div>
    <script>
        let oipt =document.querySelector(".oipt")
        let tipt=document.querySelector(".tipt")
        let btn =document.querySelector(".ff1")
        let hipt =document.querySelector(".hipt")
        let ts=document.querySelector(".ts")
        let tts=document.querySelector(".tts")
        var flg=false
        let aaa=0
        oipt.onchange=function(){
            let zh=/^[0-9]*$/
            if(zh.test(this.value)){
                flg=true
                ts.innerHTML="账号正确"
                ts.style.color="rgb(4, 223, 15)"
                aaa+=1
            }else {
                flg=false
                ts.innerHTML="账号输入错误"
                ts.style.color="red"
            }
        }
        tipt.onchange=function(){
            let ma=/^[a-z0-9_-]{3,16}$/
            if(ma.test(this.value)){
                flg=true
                tts.innerHTML="密码正确"
                tts.style.color ='rgb(4, 223, 15)'
                aaa+=1
            }else{
                flg=false
                tts.innerHTML="密码输入错误"
                tts.style.color="red"
            }
        }
        btn.onclick =async function(){
            if(hipt.checked &&aaa==2){
                let username=oipt.value
                let password=tipt.value
                let data={username,password}
                let url="http://jx.xuzhixiang.top/ap/api/reg.php"
                let r=await axios.get(url,{params:data});
                console.log(r.data);
                if(r.data.code==1 ){
                    location.href="denglu.html"
                }

            }else{
                alert("错误")
            }
        }
        
    </script>
</body>
</html>